package com.tjec.project.projectWorkbench.service.impl;

import java.util.List;
import java.util.UUID;

import com.tjec.common.utils.DateUtils;
import com.tjec.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.tjec.project.projectWorkbench.mapper.BmsProjectStakeholderMapper;
import com.tjec.project.projectWorkbench.domain.BmsProjectStakeholder;
import com.tjec.project.projectWorkbench.service.IBmsProjectStakeholderService;

/**
 * 项目干系人Service业务层处理
 * 
 * @author cjj
 * @date 2020-04-26
 */
@Service
public class BmsProjectStakeholderServiceImpl implements IBmsProjectStakeholderService 
{
    @Autowired
    private BmsProjectStakeholderMapper bmsProjectStakeholderMapper;

    /**
     * 查询项目干系人
     * 
     * @param guid 项目干系人guid
     * @return 项目干系人
     */
    @Override
    public BmsProjectStakeholder selectBmsProjectStakeholderByGuid(String guid)
    {
        return bmsProjectStakeholderMapper.selectBmsProjectStakeholderByGuid(guid);
    }

    /**
     * 查询项目干系人列表
     * 
     * @param bmsProjectStakeholder 项目干系人
     * @return 项目干系人
     */
    @Override
    public List<BmsProjectStakeholder> selectBmsProjectStakeholderList(BmsProjectStakeholder bmsProjectStakeholder)
    {
        return bmsProjectStakeholderMapper.selectBmsProjectStakeholderList(bmsProjectStakeholder);
    }

    /**
     * 新增项目干系人
     * 
     * @param bmsProjectStakeholder 项目干系人
     * @return 结果
     */
    @Override
    public int insertBmsProjectStakeholder(BmsProjectStakeholder bmsProjectStakeholder)
    {
        bmsProjectStakeholder.setCreateTime(DateUtils.getNowDate());
        bmsProjectStakeholder.setCreateBy(SecurityUtils.getLoginUser().getUser().getUserId());
        if(null==bmsProjectStakeholder.getGuid()||("").equals(bmsProjectStakeholder.getGuid())){
            bmsProjectStakeholder.setGuid(UUID.randomUUID().toString());
        }
        return bmsProjectStakeholderMapper.insertBmsProjectStakeholder(bmsProjectStakeholder);
    }

    /**
     * 修改项目干系人
     * 
     * @param bmsProjectStakeholder 项目干系人
     * @return 结果
     */
    @Override
    public int updateBmsProjectStakeholder(BmsProjectStakeholder bmsProjectStakeholder)
    {
        bmsProjectStakeholder.setUpdateTime(DateUtils.getNowDate());
        bmsProjectStakeholder.setUpdateBy(SecurityUtils.getLoginUser().getUser().getUserId());
        return bmsProjectStakeholderMapper.updateBmsProjectStakeholder(bmsProjectStakeholder);
    }

    /**
     * 批量删除项目干系人
     * 
     * @param guids 需要删除的项目干系人guids
     * @return 结果
     */
    @Override
    public int deleteBmsProjectStakeholderByGuids(String[] guids)
    {
        return bmsProjectStakeholderMapper.deleteBmsProjectStakeholderByGuids(guids);
    }

    /**
     * 删除项目干系人信息
     * 
     * @param guid 项目干系人guid
     * @return 结果
     */
    @Override
    public int deleteBmsProjectStakeholderByGuid(String guid)
    {
        return bmsProjectStakeholderMapper.deleteBmsProjectStakeholderByGuid(guid);
    }
}
